
package com.amado.springboot.springbootcms.service.impl;

import com.amado.springboot.springbootcms.domain.Depa;
import com.amado.springboot.springbootcms.domain.Goods;
import com.amado.springboot.springbootcms.domain.User;
import com.amado.springboot.springbootcms.mapper.DepaMapper;
import com.amado.springboot.springbootcms.mapper.GoodsMapper;
import com.amado.springboot.springbootcms.mapper.UserMapper;
import com.amado.springboot.springbootcms.service.DepaService;
import com.amado.springboot.springbootcms.service.GoodsService;
import com.amado.springboot.springbootcms.util.RedisTemplateDriver;
import com.amado.springboot.springbootcms.vo.UserLoginVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangyl-910
 * @description
 * @date 2017/12/4
 * @see
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    Logger logger = LoggerFactory.getLogger(GoodsServiceImpl.class);
    @Autowired
    private RedisTemplateDriver redisTemplateDriver;
    @Autowired
    private GoodsMapper goodsrMapper;

    private static final Logger LOGGER = LoggerFactory.getLogger(GoodsServiceImpl.class);
    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;



    @Override

    public void addGoods(Goods goods) {
        if(goods!=null){
            if ("".equals (goods.getName ()) &&"".equals (goods.getFatherId ())&&"".equals (goods.getDeleteFlag ())){
                LOGGER.debug("返回值" );
            }else{
                goodsrMapper.insertSelective(goods);
            }
        }

    }

    @Override

    public void deleteGoods(List<Long> id) {
        if("".equals (id)){
            LOGGER.debug("返回值" );
        }else{goodsrMapper.delete(id);}
    }

    @Override
    public Goods getGoods(Long id) {
        Goods  goods = new Goods();
        if("".equals (id)){
            LOGGER.debug("返回值" );
        }else{
             goods = goodsrMapper.get(id);
        }

        return goods;
    }







    @Override
    @Cacheable(cacheNames = "allGoods")
    public List<Goods> getAllGoods() {
        return goodsrMapper.queryAll();
    }

    @Override
    public void modifyGoods(Goods goods) {
        if ("".equals (goods.getName ()) &&"".equals (goods.getFatherId ())&&"".equals (goods.getDeleteFlag ())){

        }else{
            goodsrMapper.modify(goods);
        }

    }


}
